/*
 * @lc app=leetcode.cn id=11 lang=cpp
 *
 * [11] 盛最多水的容器
 * 
 * 双指针，每次移动较高的那一个，比较最大值
 */

// @lc code=start
class Solution {
public:
    int maxArea(vector<int>& height) {
        int ans = 0;
        int n = height.size();
        int start = 0,end = n-1;
        while(start < end) {
            int area = min(height[start],height[end])*(end - start);
            ans = max(ans,area);
            if(height[start] < height[end]) {
                ++start;
            }else {
                --end;
            }
        }
        return ans;
    }
};
// @lc code=end

